package com.ksd.modules.adminlogs.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ksd.common.controller.BaseController;
import com.ksd.common.core.result.R;
import com.ksd.modules.adminlogs.entity.SysLog;
import com.ksd.modules.adminlogs.po.SysLogSavePO;
import com.ksd.modules.adminlogs.po.SysLogSearchPO;
import com.ksd.modules.adminlogs.service.ISysLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 系统日志表 前端控制器
 * </p>
 *
 * @author Auto Generator
 * @since 2023-08-16
 */
@RestController
public class SysLogController extends BaseController {

    @Autowired
    private ISysLogService adminSysLogService;

    /**
     * 查询系统日志接口
     * @param adminMayaAdvertsSearchPO
     * @return
     */
    @PostMapping("/adminlogs/list")
    public R<Page<SysLog>> findSysLog(@Validated @RequestBody SysLogSearchPO adminMayaAdvertsSearchPO){
        return R.data(adminSysLogService.findSysLog(adminMayaAdvertsSearchPO));
    }

    /**
     * 保存和更新
     * @param adminMayaAdvertsSavePO
     * @return
     */
    @PostMapping("/adminlogs/saveupdate")
    public R<Boolean> saveUpdateSysLog(@Validated @RequestBody SysLogSavePO adminMayaAdvertsSavePO){
        return R.data(adminSysLogService.saveUpdateSysLog(adminMayaAdvertsSavePO));
    }

    /**
     * 根据id查询系统日志
     * @param id
     * @return
     */
    @PostMapping("/adminlogs/get/{id}")
    public R<SysLog> getSysLogById(@PathVariable("id")Long id){
        return R.data(adminSysLogService.getSysLogById(id));
    }

    /**
     * 根据id删除系统日志
     * @param id
     * @return
     */
    @PostMapping("/adminlogs/del/{id}")
    public R<Boolean> delSysLogById(@PathVariable("id")Long id){
        return R.data(adminSysLogService.deleteSysLogById(id));
    }
}
